home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12448 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  54 lines

  1. Path: howland.reston.ans.net!psinntp!psinntp!psinntp!psinntp!usenet
  2. From: grantp@usa.pipeline.com(Pete Grant)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Question on writing DLL
  5. Date: 20 Mar 1996 01:12:13 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4inm1d$88g@news1.h1.usa.pipeline.com>
  8. References: <4img25$75t@ustsu10.ust.hk>
  9. NNTP-Posting-Host: 38.8.53.2
  10. X-PipeUser: grantp
  11. X-PipeHub: usa.pipeline.com
  12. X-PipeGCOS: (Pete Grant)
  13. X-Newsreader: Pipeline v3.5.0
  14.  
  15. On Mar 19, 1996 14:24:05 in article <Question on writing DLL>,
  16. 'cs_billy@ug.cs.ust.hk (Ng Ka Fai)' wrote: 
  17.  
  18.  
  19. >Hello all, 
  20. >I am a new learner of DLL and I want to write a testing program on it and 
  21. >call the DLL from a macro of MS-word. However, error message display 
  22. >"Unable to open the specified library" ! What's wrong with it? I suspect 
  23. >that the DLL in Borland C++ (4.5) I written was wrong.  
  24. >Could anyone help me? Please. 
  25. >In macro 
  26. >-------- 
  27. >Declare Function Abc Lib "c:\TEST.DLL" () As Integer 
  28. >Sub MAIN 
  29. >a = Abc() 
  30. >MsgBox Str$(a), "TEST" 
  31. >End Sub 
  32. >In DLL 
  33. >------ 
  34. >#include <stdio.h> 
  35. >#include <windows.h> 
  36. I assume a 16-bit system. 
  37.  
  38. extern "C" 
  39. >int FAR PASCAL _export Abc() 
  40.  
  41. You need the extern "C" to suppress name mangling. 
  42. PASCAL is necessary to suppress the prepending of 
  43. an underscore and to force the symbol to all upper case. 
  44.  
  45. -- 
  46. Pete Grant 
  47. Kalevi, Inc. 
  48. Software Engineering & development
  49.